package com.ruoyi.bizsys.controller;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bizsys.domain.ZollectionExcludePhone;
import com.ruoyi.bizsys.service.IZollectionExcludePhoneService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 催收剔除手机号Controller
 *
 * @author african-loan
 * @date 2022-02-17
 */
@RestController
@RequestMapping("/bizsys/phone")
public class ZollectionExcludePhoneController extends BaseController {
    @Autowired
    private IZollectionExcludePhoneService zollectionExcludePhoneService;

/**
 * 查询催收剔除手机号列表
 */
@PreAuthorize("@ss.hasPermi('bizsys:phone:list')")
@GetMapping("/list")
        public TableDataInfo list(ZollectionExcludePhone zollectionExcludePhone) {
        startPage();
        List<ZollectionExcludePhone> list = zollectionExcludePhoneService.selectZollectionExcludePhoneList(zollectionExcludePhone);
        return getDataTable(list);
    }
    
    /**
     * 导出催收剔除手机号列表
     */
    @PreAuthorize("@ss.hasPermi('bizsys:phone:export')")
    @Log(title = "催收剔除手机号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZollectionExcludePhone zollectionExcludePhone) {
        List<ZollectionExcludePhone> list = zollectionExcludePhoneService.selectZollectionExcludePhoneList(zollectionExcludePhone);
        ExcelUtil<ZollectionExcludePhone> util = new ExcelUtil<ZollectionExcludePhone>(ZollectionExcludePhone.class);
        return util.exportExcel(list, "phone");
    }

    /**
     * 获取催收剔除手机号详细信息
     */
    @PreAuthorize("@ss.hasPermi('bizsys:phone:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(zollectionExcludePhoneService.selectZollectionExcludePhoneById(id));
    }

    /**
     * 新增催收剔除手机号
     */
    @PreAuthorize("@ss.hasPermi('bizsys:phone:add')")
    @Log(title = "催收剔除手机号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZollectionExcludePhone zollectionExcludePhone) {
        return toAjax(zollectionExcludePhoneService.insertZollectionExcludePhone(zollectionExcludePhone));
    }

    /**
     * 修改催收剔除手机号
     */
    @PreAuthorize("@ss.hasPermi('bizsys:phone:edit')")
    @Log(title = "催收剔除手机号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZollectionExcludePhone zollectionExcludePhone) {
        return toAjax(zollectionExcludePhoneService.updateZollectionExcludePhone(zollectionExcludePhone));
    }

    /**
     * 删除催收剔除手机号
     */
    @PreAuthorize("@ss.hasPermi('bizsys:phone:remove')")
    @Log(title = "催收剔除手机号", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(zollectionExcludePhoneService.deleteZollectionExcludePhoneByIds(ids));
    }
}
